package com.xuce.nzshopuserweb.client;


import com.xuce.constant.CookieConstant;
import com.xuce.dto.ResultBean;
import com.xuce.pojo.TUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@FeignClient(value = "user-service")
public interface UserServiceClient {
    @PostMapping("user/register/email")
    ResultBean registerByEmail(TUser user);

    @RequestMapping("register")
    ResultBean register(@RequestParam String uname, @RequestParam String password);

//    @PostMapping("user/checkLogin")
//    String checkLogin(@RequestParam String uname
//                    , @RequestParam String password
//                    , @RequestParam HttpServletResponse response
//                    , @RequestParam  @CookieValue(name = CookieConstant.USER_CART,required = false)String userCartUuid
//    );
//    @PostMapping("user/checkLogin")
//    ResultBean checkLogin(@RequestParam String uname
//                         , @RequestParam String password
////            TUser user
//    );

//     返回ResultBean
    @PostMapping("user/checkLogin")
    ResultBean checkLogin(@RequestParam String uname,@RequestParam String password,
                          @RequestParam HttpServletResponse response,
                          @RequestParam @CookieValue(name = CookieConstant.USER_CART,required = false)String userCartUuid
    );


    /**
     * 判断用户是否已登录
     */
    @RequestMapping("user/checkIsLogin")
    @ResponseBody
    ResultBean checkIsLogin(@RequestParam @CookieValue(name = CookieConstant.USER_LOGIN,required = false) String uuid,@RequestParam HttpServletRequest request);


    /**
     * 注销
     */
    @RequestMapping("user/logout")
    @ResponseBody
    ResultBean logout(@RequestParam @CookieValue(name=CookieConstant.USER_LOGIN,required = false) String uuid,
                      @RequestParam HttpServletResponse response);

}
